package com.tencreat.common.core.domain.dto;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 入参分页
 *
 * @author zixin
 */
public class BaseEntityDTO<T extends Model<?>> extends Model<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("当前页数")
    @TableField(exist = false)
    private Integer current;

    @ApiModelProperty("每页显示条数")
    @TableField(exist = false)
    private Integer size;

    @TableField(exist = false)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("开始时间")
    private LocalDateTime startTime;

    @TableField(exist = false)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty("结束时间")
    private LocalDateTime endTime;

    /**
     * 已废弃，但仍可使用
     * 尽量使用 current
     */
    @Deprecated
    @ApiModelProperty(value = "当前页数", hidden = true)
    @TableField(exist = false)
    private Integer pageNum;

    /**
     * 已废弃，但仍可使用
     * 尽量使用 size
     */
    @Deprecated
    @ApiModelProperty(value = "每页显示条数", hidden = true)
    @TableField(exist = false)
    private Integer pageSize;

    /**
     * 租户号
     */
    @TableField("`tenant_id`")
    @ApiModelProperty(hidden = true)
    private Long tenantId;

    /**
     * 删除标志
     */
    @TableLogic
    @TableField("`del_flag`")
    @ApiModelProperty(hidden = true)
    private String delFlag;

    /**
     * 乐观锁
     */
    @TableField(value = "`revision`", exist = false)
    @ApiModelProperty(hidden = true)
    private Long version;

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getPageNum() {
        return pageNum;
    }

    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public LocalDateTime getStartTime() {
        return startTime;
    }

    public void setStartTime(LocalDateTime startTime) {
        this.startTime = startTime;
    }

    public LocalDateTime getEndTime() {
        return endTime;
    }

    public void setEndTime(LocalDateTime endTime) {
        this.endTime = endTime;
    }

    public Integer getCurrent() {
        return current;
    }

    public String getDelFlag() {
        return delFlag;
    }

    public void setVersion(Long version) {
        this.version = version;
    }

    public Long getVersion() {
        return version;
    }

    public void setTenantId(Long tenantId) {
        this.tenantId = tenantId;
    }

    @ApiModelProperty(hidden = true)
    public Long getTenantId() {
        return tenantId;
    }

    public void setDelFlag(String delFlag) {
        this.delFlag = delFlag;
    }

    public void setCurrent(Integer current) {
        this.current = current;
    }

    public Integer getSize() {
        return size;
    }

    public void setSize(Integer size) {
        this.size = size;
    }

    @Override
    public String toString() {
        return "BasePageEntityDTO{" +
                "current=" + current +
                ", size=" + size +
                '}';
    }
}
